home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / tutorials / plugin / tutorial / tutorial.cpp next >
Encoding:
C/C++ Source or Header  |  2000-06-30  |  2.1 KB  |  127 lines

  1. #include "..\..\lib\Fly3D.h"
  2. #include "tutorial.h"
  3.  
  4. blink_light_desc cd_blink_light;
  5. bounce_mesh_desc cd_bounce_mesh;
  6.  
  7. BOOL APIENTRY DllMain(HINSTANCE hModule, 
  8.                       DWORD  ul_reason_for_call, 
  9.                       LPVOID lpReserved)
  10. {    
  11.     switch( ul_reason_for_call ) 
  12.     {
  13.     case DLL_PROCESS_ATTACH:
  14.     case DLL_THREAD_ATTACH:
  15.     case DLL_THREAD_DETACH:
  16.     case DLL_PROCESS_DETACH:
  17.         break;
  18.     }
  19.     return TRUE;
  20. }
  21.  
  22. __declspec( dllexport )
  23. int num_classes()
  24. {
  25.     return 2;
  26. }
  27.  
  28. __declspec( dllexport )
  29. class_desc *get_class_desc(int i)
  30. {
  31.     switch(i)
  32.     {
  33.     case 0:
  34.         return &cd_blink_light;
  35.     case 1:
  36.         return &cd_bounce_mesh;
  37.     default: return 0;
  38.     }
  39. }
  40.  
  41. __declspec( dllexport )
  42. int fly_message(int msg,int param,void *data)
  43. {
  44.     switch(msg)
  45.     {
  46.     case FLYM_UPDATESCENE:
  47.         // step/draw plugin layer
  48.         break;
  49.     }
  50.     return 1;
  51. }
  52.  
  53. int blink_light::step(int dt)
  54. {
  55.   // compute current radius 
  56.   float r=illumradius*
  57.           ((flyengine->cur_time%blinktime)/1000.0f);
  58.  
  59.   // illuminate around
  60.   flyengine->send_bsp_message( 
  61.          flyengine->bsp, pos, r, FLYOBJM_ILLUM, 0, &color);
  62.  
  63.   // return 0 as we have not moved (changed pos)
  64.    return 0;
  65.  
  66. void blink_light::draw()
  67. {
  68.     // TODO: draw using opengl
  69. }
  70.  
  71. bsp_object *blink_light::clone()
  72. {
  73.     blink_light *tmp=new blink_light;
  74.     *tmp=*this;
  75.     tmp->source=this;
  76.     return tmp;
  77. }
  78.  
  79. int blink_light::get_custom_param_desc(int i,param_desc *pd)
  80. {
  81.     if (pd!=0)
  82.     switch(i)
  83.     {
  84.     case 0:
  85.         pd->type='c';
  86.         pd->data=&color;
  87.         strcpy(pd->name,"color");
  88.         break;
  89.     case 1:
  90.         pd->type='f';
  91.         pd->data=&illumradius;
  92.         strcpy(pd->name,"illumradius");
  93.         break;
  94.     case 2:
  95.         pd->type='i';
  96.         pd->data=&blinktime;
  97.         strcpy(pd->name,"blinktime");
  98.         break;
  99.     }
  100.     return 3;
  101. }
  102.  
  103. bsp_object *bounce_mesh::clone()
  104. {
  105.     bounce_mesh *tmp=new bounce_mesh;
  106.     *tmp=*this;
  107.     tmp->source=this;
  108.     return tmp;
  109. }
  110.  
  111. int bounce_mesh::get_custom_param_desc(int i,param_desc *pd)
  112. {
  113.     if (pd!=0)
  114.     switch(i)
  115.     {
  116.     case 0:
  117.         pd->type='3';
  118.         pd->data=&objmesh;
  119.         strcpy(pd->name,"objmesh");
  120.         break;
  121.     }
  122.     return 1;
  123. }
  124.  
  125.  
  126.